var baseUrl = '';
const WORKUNITID = 9307;

//#ifdef MP-WEIXIN
baseUrl = 'https://sngj.cangyun.cn:38916';//'http://58.67.161.51:38916';
// #endif
export default class http {
	//get请求
	static get(url, callback) {
		uni.request({
			method:'GET',
			url: baseUrl + url,
			header: {
				'content-type': 'application/json;charset=utf-8', 
			},
			success: (res) => {
				callback(res.data);
			}
		});
	}

	//POST请求
	static post(url, params = {}, callback) {
		params.workUnitID = WORKUNITID;
		uni.request({
			method:'POST',
			url: baseUrl + url,
			data: params,
			header: {
				'content-type': 'application/json;charset=utf-8', 
			},
			success: (res) => {
				callback(res.data);
			}
		});
	}

	static fileUpload(url, file, params = {}, callback) {
		params.workUnitID = WORKUNITID;
		uni.uploadFile({
			url: baseUrl + url,
			filePath: file,
			name: 'file',
			formData: params,
			success: function(res) {
				callback(res.data);
			}
		});
	}
	static delete(url,params={},callback){
		uni.request({
			method:'DELETE',
			url: baseUrl + url,
			data: params,
			header: {
				'content-type': 'application/json;charset=utf-8', 
			},
			success: (res) => {
				callback(res.data);
			}
		});
	}
}
